package org.ccams.dao;


import java.util.HashMap;
import java.util.List;

import org.ccams.domain.TRights;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
/**
 * 权限dao
 * @author liuguangshuai@gmail.com
 * @系统名称：定制化辅助生成制造系统
 * @时间：Aug 10, 2008
 */
public class TRightsDao extends SqlMapClientDaoSupport {
	
	
	/**
	 * 根据指定角色获得权限菜单
	 * @param rId
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  List<TRights> getATRightsByRid(String id){
		return getSqlMapClientTemplate().queryForList("TRights.getTRightsByJS",id);		
	}
	/**
	 * 根据指定角色获得权限菜单
	 * @param rId
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  HashMap<String,String> getTMenuByRid(String id){
		HashMap<String,String> hs = new HashMap<String,String>();
		List<TRights> list= getSqlMapClientTemplate().queryForList("TRights.getTRightsByJS",id);
		for(TRights t : list){
			hs.put("菜单"+t.getMId(), "1");
		}
		return hs;
	}
	/**
	 * add Entity
	 * @param t
	 * @return
	 */
	public int insertTRights(TRights t ){
		return getSqlMapClientTemplate().update("TRights.addTRights", t);
	}
	/**
	 * 根据角色delete Entity
	 * @param id
	 * @return
	 */
	public int deleteTRights(String id){
		return getSqlMapClientTemplate().update("TRights.deleteTRights", id);
	}
}
